<template>
	<view class="container">
		<view class="context">
			<view class="title">委托书</view>
			<view class="line indent">本人<text class="underline">{{RealName}}</text>，身份证号<text class="underline">{{IDCard}}</text>，自愿提供自己的信息，同意授权郑青春约会吧向第三方认证自己的婚姻信息，学历信息，包含但不限于上述信息，同意郑青春约会吧公益交友平台的注册协议和隐私协议。</view>
			<view class="namedate" v-if="SignNameOld==''">
				<view class="name">
					<view class="weituo1">委托人：</view>
					<view class="signname1"><image v-if="SignName!=''" :src="SignName" /></view>
				</view>
				<view class="date1">{{CurrDate}}</view>
			</view>
			
			<view class="namedate" v-if="SignNameOld!=''">
				<view class="name">
					<view class="weituo2">委托人：</view>
					<view class="signname2" v-if="SignNameOld!=''"><image v-if="SignNameOld!=''" :src="SignNameOld" /></view>
				</view>
				<view class="date2">{{CurrDate}}</view>
			</view>
		</view>
		<template v-if="IsIdentify==0">
			<template v-if="SignNameOld==''">
				<view v-if="SignName==''" class="publish sign" @click="Sign">点此签名</view>
				<view v-else class="publish sign" @click="Save">确定</view>
			</template>
			<template v-else>
				<view class="publish sign" @click="Sign">重新签名</view>
			</template>
		</template>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				RealName:'',
				IDCard:'',
				Protocol:'',
				SignNameOld:'',
				SignName:'',
				CurrDate:'',
				IsIdentify:0
			};
		},
		onLoad(options) {
			this.IsIdentify=options.IsIdentify;
			this.SignNameOld=options.SignName;
			this.RealName=options.RealName;
			this.IDCard=options.IDCard;
			this.CurrDate= new Date().Format("yyyy年MM月dd日");
			uni.$on('q-sign',path =>{
				this.SignName=path;
				this.SignNameOld='';
				
			})
		},
		methods:{
			Sign(){
				uni.navigateTo({
					url:'q-sign'
				})
			},
			Save(){
				this.Util.Loading("请稍候...");
				this.Util.OneUpload(this.SignName,"upload_file_signname",json=>{
					this.SaveSignName(json.Data.Path);
				});
			},
			SaveSignName(SignName){
				var data={};
				data.Act="Save_SignName";
				data.RealName = this.RealName;
				data.IDCard = this.IDCard;
				data.SignName = SignName;
				this.Util.Post(data, json=>{
					this.Util.HideLoading();
					if(json.State){
						uni.$emit("IsSign",{IsSign:1, SignName:SignName});
						this.Util.Toast(json.Msg, ()=>{
							uni.navigateBack();
						});
					}else{
						this.Util.Alert(json.Msg);
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	page{background-color: #ffffff;}
	.context{width:100%; height:auto; padding:30rpx;
		.title{width:100%; height:80rpx; line-height: 80rpx; text-align: center; font-size:38rpx; font-weight: bold;}
		.line{width:100%; min-height: 50rpx; line-height: 50rpx; word-wrap:break-word;word-break:break-all;}
		.namedate{width:100%; margin-top:250rpx; padding-right: 30rpx;
			.name{width:100%; display: flex; flex-direction: row; justify-content: flex-end;
				.weituo1{width:auto; margin-right: 35rpx;}
				.weituo2{width:auto; margin-right: 0rpx;}
				.signname1{width:80rpx; height: 180rpx; margin-top:-70rpx; transform: rotate(-90deg); image{width:100%; height:100%;}}
				.signname2{width:180rpx; height: 80rpx; margin-top:-10rpx; image{width:100%; height:100%;}}
			}
			.date1{width:100%; text-align: right; margin-top:-50rpx;}
			.date2{width:100%; text-align: right; margin-top:0rpx;}
		}
	}
</style>
